/**
 * Created by dasd on 2017/1/11.
 * 1.左侧菜单的点击操作
 *
 */
$(function() {
    // 左侧手风琴菜单
    var ul = $('#sidebar > ul');
    $("#sidebar").on("click", ".submenu > a", function() {
        var submenu = $(this).siblings('ul');
        var li = $(this).parents('li');
        var submenus = $('#sidebar li.submenu ul');
        var submenus_parents = $('#sidebar li.submenu');
        if (li.hasClass('open')) {
            if (($(window).width() > 768) || ($(window).width() < 479)) {
                submenu.slideUp();
            } else {
                submenu.fadeOut(250);
            }
            li.removeClass('open');
        } else {
            if (($(window).width() > 768) || ($(window).width() < 479)) {
                submenus.slideUp();
                submenu.slideDown();
            } else {
                submenus.fadeOut(250);
                submenu.fadeIn(250);
            }
            submenus_parents.removeClass('open');
            li.addClass('open');
        }
    });
    // 菜单选中
    $("#sidebar").on("click",".submenu > ul > li",function () {
        $(this).addClass('active').siblings().removeClass('active');
    });
    // 菜单加载
    var menuObj = {"list":[{"menuName":"123","child":[{"menuName":"123"},{"menuName":"456"}]},{"menuName":"456"}],"menuIcoArr":menuIcoArr};
    var navHtml = template('tests', menuObj);
    $("#sidebar").find("ul").empty().append(navHtml);
});

/*
 *一级菜单图标
 */
var menuIcoArr = [];
menuIcoArr['管理桌面'] = 'icon-home';
menuIcoArr['456'] = 'icon-glass';
menuIcoArr['123'] = 'icon-th';
menuIcoArr['会员管理'] = 'icon-user';
menuIcoArr['系统设置'] = ' icon-asterisk';
menuIcoArr['信息发布'] = 'icon-road';
menuIcoArr['财务管理'] = 'icon-list';
menuIcoArr['系统维护'] = 'icon-indent-left';
menuIcoArr['客服管理'] = 'icon-user';
menuIcoArr['风控管理'] = 'icon-camera';
menuIcoArr['风险管理'] = 'icon-camera';
menuIcoArr['系统支撑'] = 'icon-hdd';
menuIcoArr['加盟店/代理'] = 'icon-stop';
menuIcoArr['问卷回访'] = 'icon-list-alt';
menuIcoArr['设置管理'] = 'icon-certificate';
menuIcoArr['加盟店管理'] = 'icon-resize-full';
menuIcoArr['代理管理'] = 'icon-random ';
menuIcoArr['直营机构统计数据'] = 'icon-globe';
menuIcoArr['垫付宝违约欠款'] = 'icon-exclamation-sign';
menuIcoArr['广告管理'] = 'icon-globe';
menuIcoArr['加油卡'] = 'icon-homecard';
menuIcoArr['ETC卡'] = 'icon-etccard';